﻿using GS_OM.SMDB;
using SMDB_Connect.SMDB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.SessionState;

namespace GS_OM.Pages
{
    /// <summary>
    /// testHandler 的摘要说明
    /// </summary>
    public class testHandler : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            SMDB_Mgr Mgr = new SMDB_Mgr();

            string n= context.Session["SID"].ToString();
            List<DBOPush> PushList = Mgr.GetPushByID(n);            
            foreach (DBOPush Push in PushList)
            {
                Push.Push_Approval = ToolsClass.PushApprovalTrans(Push.Push_Approval);
                Push.Push_Type = ToolsClass.PushTypesTrans(Push.Push_Type);
                Push.Push_Res =Mgr.GetResByPush(Push.Push_ID.ToString())==null?"../files/img/small_img/photoframe.png":(Mgr.GetResByPush(Push.Push_ID.ToString()) as List<DBOPushRes>).FirstOrDefault().Res_Path;
            }
            JavaScriptSerializer jss = new JavaScriptSerializer();
            string s= jss.Serialize(PushList);
            context.Response.Write(s);
            context.Response.End();

        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}